<?php
global $_GPC, $_W;
$GLOBALS['frames'] = $this->getMainMenu2();
if (empty($_GPC['state'])) {
  $_GPC['state'] = 0;
}
$where=" where uniacid=:uniacid and city_id=:city_id and cid=:cid and state=:state";
$data[':uniacid']=$_W['uniacid']; 
$data[':city_id']= $_COOKIE['account_id'];
$data[':cid']= $_GPC['cid'];
$data[':state']= $_GPC['state'];

if(isset($_GPC['keywords'])){
    $where.=" and code LIKE  concat('%', :name,'%') ";
    $data[':name']=$_GPC['keywords']; 
}


$pageindex = max(1, intval($_GPC['page']));
$pagesize=10;
$sql="select * from".tablename('zhtc_qrcode_data') ."".$where." ORDER BY id DESC";


$total=pdo_fetchcolumn("select count(*) from".tablename('zhtc_qrcode_data')."".$where,$data);
$select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
$list=pdo_fetchall($select_sql,$data);


$pager = pagination($total, $pageindex, $pagesize);
if($_GPC['op']=='delete'){
    $res=pdo_delete('zhtc_qrcode_data',array('id'=>$_GPC['id']));
    if($res){
      message('删除成功！', $this->createWebUrl('codedata'), 'success');
    }else{
      message('删除失败！','','error');
    }
}
include $this->template('web/codedata');